﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Tour.BLL;
using Tour.DAL;

public partial class Controls_Tourist_TourList : System.Web.UI.UserControl
{    
    public static int PageSize = 6;
    public int PageIndex { get; set; }
    public string TypeTextID { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        //int TotalRow = 0;
        PageIndex = CommonHelper.QueryStringInt("page", 1);
        TypeTextID = CommonHelper.QueryString("TypeTextID");
        if (!IsPostBack)
        {
            LoadData();
            LoadTourType();
        }
    }
    void LoadData()
    {
        int TotalRow = 0;
        //rpt.DataSource = TblTourManager.CreateInstant().SelectTblTourBy(null, null,TypeTextID, "", null, null, null, null, PageSize, PageIndex, out TotalRow, "CreatedDate", "DESC");
        //rpt.DataBind();
        rpt.DataSource = TblTourManager.CreateInstant().tr_SelectTblTourByTourTypeAllChild(null, TypeTextID, null, null, null, null, PageSize, PageIndex, out TotalRow, "CreatedDate", "DESC");
        rpt.DataBind();
        smartPager.PageSize = PageSize;
        smartPager.QueryStringKey = "page";
        smartPager.RowCount = TotalRow;
        smartPager.UrlFormatString = UrlBuilder.GetTourListPagingUrl(TypeTextID);
        smartPager.Visible = TotalRow > PageSize;
    }
    void LoadTourType()
    {
        //int TotalRow = 0;
        rptTourType.DataSource = TblTourTypeManager.CreateInstant().SelectTblTourTypeBy(null, null, null, TypeTextID, true, "Id", "DESC");
        rptTourType.DataBind();       
    }
}